﻿using Harmontronics.DataAccess.IOperate.Business;
using Harmontronics.Model.Common;
using Harmontronics.Model.Dto.Model;
using Harmontronics.Model.Entitys;
using Harmontronics.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Harmontronics.DataAccess.Operate.Business
{
    public class ProcessOperate : IProcessOperate
    {
        private HcDbContext _db { get; set; }
        public ProcessOperate(HcDbContext db)
        {
            _db = db;
        }
        //查询所有
        public List<Process> GetAllProcessList()
        {

            return _db.Processes.ToList();
        }

        public Process GetProcessById(string id)
        {
            return _db.Processes.SingleOrDefault(i => i.ProcessId == id);
        }

        public void AddProcess(Process entity)
        {
            _db.Processes.Add(entity);
        }

        public void UpdateProcess(Process entity)
        {
            _db.Processes.Update(entity);
        }

        public void DeleteProcess(Process entity)
        {
            _db.Processes.Remove(entity);

        }

        public void BatchDelProcess(List<Process> entities)
        {
            _db.Processes.RemoveRange(entities);

        }

        public List<Process> GetProcessByIdList(List<string> ids)
        {
            return _db.Processes.Where(i => ids.Contains(i.ProcessId)).ToList();
        }
    }
}
